﻿#pragma once
#include "XyNet/Common/Id.h"

namespace XyNet
{
	class RpcSocketChannel;

	/// 会话管理器
	class XYNET_API RpcSocketChannelManager
	{
	public:
		/// 添加套接字通道
		void addSocketChannel(shared_ptr<RpcSocketChannel> socketChannel);
		/// 移除套接字通道
		void removeSocketChannel(shared_ptr<RpcSocketChannel> socketChannel);

		/// 获取套接字通道数量
		int getSocketChannelCount() const;
		/// 查找套接字通道
		shared_ptr<RpcSocketChannel> findSocketChannel(const Id& socketChannelId) const;

		/// 获取所有套接字通道列表
		vector<shared_ptr<RpcSocketChannel>> getSocketChannels() const;
		/// 查找符合条件的套接字通道列表
		vector<shared_ptr<RpcSocketChannel>> findSocketChannels(
			function<bool(shared_ptr<RpcSocketChannel>)> predicate) const;

	private:
		/// 套接字通道映射对象
		SharedObject<map<Id, shared_ptr<RpcSocketChannel>>> _socketChannelMapObject;
	};
}